<?php

// retrieve the path of the configuration file
$confFile = null;

for($i=1;$i<count($argv);$i++){
    if(substr($argv[$i],0,7)==='--conf=') {
        $confFile = substr($argv[$i],7);
    }elseif(substr($argv[$i],0,15)==='--include-path=') {
        set_include_path(get_include_path().PATH_SEPARATOR.substr($argv[$i],15));
    }
}

if($confFile===null) {
	echo "No configuration file specified. Using default configuration.\n";
    echo "To specify custom settings, you can use option\n\t--conf=<path/to/your/configuration/file.ini>\n";
}

require_once dirname(__FILE__) . '/bootstrap.php';

// instantiates and runs LightBot
try {
    $daemon = new LightJob_LightJob();
    $daemon->configure($confFile);
    $daemon->run();
} catch(Exception $e) {
    echo "Error: ".$e->getMessage()."\n";
    exit;
}
